<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="../../org/angular.min.js"></script>
</head>

<body ng-app="app" ng-controller="ctrl">
    <span ng-bind="name"></span>
    <hr> {{num}}
    <script>
        var m = angular.module('app', []);
        m.controller('ctrl', ['$scope', '$timeout', '$interval', function($scope, $timeout, $interval) {
            $scope.name = '老周';
            // setTimeout(function() {
            //     $scope.name = 'zyx';
            //     $scope.$apply();
            // }, 1000);
            // ================
            // $timeout
            // var timer = $timeout(function() {
            //     $scope.name = 'zyx';
            // }, 1000);
            // //清楚定时器
            // $timeout.cancel(timer);

            // // ================
            // $interval
            $scope.num = 0;
            var timer = $interval(function() {
                $scope.num++;
                if ($scope.num > 5) {
                    $interval.cancel(timer);
                }
            }, 1000);
        }])
    </script>
</body>

</html>
